package com.one.controller;

import com.one.annotation.RequestPermission;
import com.one.service.CommentService;
import com.one.util.RequestReturn;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;



/**
 * @author: tzy
 * @create: 2022/1/19
 * @FileName: CommentController
 * @Description: 评论操作入口
 */
@Slf4j
@Api(tags = "M.评论操作入口")
@RestController
public class CommentController {
    @Autowired
    private CommentService commentService;

   /**
    * @author: tzy
    * @date: 2022/1/20
    * @return: com.one.util.RequestResult<java.lang.String>
    * @Description: 根据用户的订单号，进行评论
    */
   @RequestPermission
   @ApiImplicitParams({
           @ApiImplicitParam(name = "ordersId", required = true, value = "订单详情表id"),
           @ApiImplicitParam(name = "commentImage", required = false, value = "评论图片 "),
           @ApiImplicitParam(name = "content", required = false, value = "评论内容"),
   })
    @ApiOperation(value = "添加评论", notes = "根据传入的订单号，和评论详情添加评论")
    @GetMapping("/addComment")
    public RequestReturn<String> addComment(@RequestParam(value = "commentImage",required = false) String commentImage,
                                            @RequestParam("content") String content,
                                            @RequestParam("ordersId") Integer ordersId){
        return commentService.addComment(commentImage,content,ordersId);
    }


    /**
     * @author: tzy
     * @date: 2022/1/20
     * @return: com.one.util.RequestResult<java.lang.String>
     * @Description: 根据评论id删除评论
     */
    @RequestPermission
    @ApiOperation(value = "删除评论", notes = "可以根据评论id进行评论的删除")

    @ApiImplicitParam(name = "commentId", value = "评论id")
    @GetMapping("/removeComment")
    public RequestReturn<String> removeComment(@RequestParam("commentId") Integer commentId){
        return commentService.removeComment(commentId);
    }


}

